home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / progs / editor / frexxed / fpl / recentfiles.fpl < prev    next >
Text File  |  1996-01-29  |  2KB  |  102 lines

  1. string menuname="Recent files";
  2. int    menupos=-1;
  3.  
  4. string files[11];
  5. int myitem,existitems;
  6.  
  7. int FindEntry(string name,int menu)
  8. {
  9.  string title,anme,fpl,key;
  10.  int myentry;
  11.  myentry=0;anme="";
  12.  while ((strcmp(anme,name))&&(myentry<64)){
  13.  myentry++;
  14.  MenuRead(&title,&anme,&fpl,&key,menu,myentry);
  15.  }
  16.  return(myentry);
  17.  
  18. }
  19.  
  20. void ReadProjectMenu()
  21. {
  22.  int cnt;
  23.  string title,fpl,key,iname;
  24.  if (64==(myitem=FindEntry(menuname,1)))
  25.  {
  26.  MenuAdd("i","Recent files","","",1,menupos);
  27.  MenuBuild();myitem=FindEntry(menuname,1);
  28.  }
  29.  existitems=0;
  30.  for(cnt=1;cnt<11;cnt++){files[cnt]="";};
  31.  for(cnt=1;cnt<64;cnt++)
  32.  {
  33.   MenuRead(&title,&iname,&fpl,&key,1,myitem,cnt);
  34.   if (! strcmp(title,"subitem"))
  35.    {
  36.     if (cnt<11){files[cnt]=iname;};
  37.     existitems++;
  38.    } ;
  39.  }
  40. }
  41.  
  42. void AddFile(string name)
  43. {
  44.  int cnt,ispresent;
  45.  ReadProjectMenu();
  46.  ispresent=0;
  47.  for (cnt=1;cnt<10;cnt++){if (! strcmp(name,files[cnt])){ispresent=1;};}
  48.  if (! ispresent){
  49.  files[0]=name;
  50.  for (cnt=0;cnt<existitems;cnt++){MenuDelete(1,myitem,1);};
  51.  for (cnt=0;cnt<10;cnt++)
  52.  {
  53.   if (strlen(files[cnt]))
  54.    {
  55.      MenuAdd("s",files[cnt],
  56.      joinstr("Open(\"",files[cnt],"\");")
  57.      ,"",1,myitem,cnt+1);
  58.    }
  59.  }
  60.  MenuBuild();
  61.  }
  62. }
  63.  
  64. export int SaveHotList()
  65. {
  66.   int cnt,bid,obid;
  67.   ReadProjectMenu();
  68.   obid=CurrentBuffer(PrevBuffer());
  69.   bid=New();
  70.   CurrentBuffer(bid);
  71.   for (cnt=1;cnt<11;cnt++){Output(files[cnt]);Output("\n");};
  72.   Clean("Save(\"FrexxEd:FilesHotList\");");
  73.   CurrentBuffer(obid);Kill(bid);
  74.   return(0);
  75. }
  76.  
  77. export int NewHotEntry()
  78. {
  79.  AddFile(ReadInfo("full_file_name"));
  80.  return(0);
  81. }
  82.  
  83. void InitMenuAndList()
  84. {
  85.  int bid,obid,done;
  86.  string filename;
  87.  ReadProjectMenu();
  88.  obid=CurrentBuffer(PrevBuffer());
  89.  bid=New();
  90.  CurrentBuffer(bid);done=1;Clean("Load(\"FrexxEd:FilesHotList\");");
  91.  while (done)
  92.  {
  93.   filename=GetLine();CursorDown();filename=substr(filename,0,strlen(filename)-1);
  94.   if (strlen(filename)) { AddFile(filename);}else{done=0;}; 
  95.  }
  96.  CurrentBuffer(obid);Kill(bid);
  97. }
  98.  
  99. Hook("QuitAll", "SaveHotList();");
  100. Hook("Save", "NewHotEntry();");
  101. InitMenuAndList();
  102.